export default {
    namespaced: true,
    //捕获用户行为
    actions: {
      function1(context, value) {
        console.log(context, value);
      },
    },
    //用于操作数据
    mutations: {
      //一般来说，这里只进行数据的计算不进行逻辑判断【类似于Dao层】
      FUNCTION1(state, value) {
        console.log("mutations收到了数据", state, value);
      },
      updateState(state, res) {
        // 存放数据到user对应的仓库
        state.userId = res.data.user.userId;
        state.nickname = res.data.user.nickname;
        state.userImg = res.data.user.userImg;
        state.token = res.data.token;
      },
      setUser(state, user) {
        //存放数据到仓库中
        console.log(state);
        state.userId = user.id;
        state.nickName = user.nickname;
        state.userImg = user.userImg;
        state.token = user.token;
        console.log(state);
      },
      test(state, value1, value2) {
        console.log("==============");
        console.log(state);
        console.log(value1);
        console.log(value2);
      },
      clearState(state) {
        //注销的时候清空仓库，在另一个地方清除cookie
        state.userId = "";
        state.nickName = "";
        state.userImg = "";
        state.token = "";
      },
    },
    //用于存储当前登录用户的数据
    state: {
      userId: -1,
      nickname: "",
      userImg: "",
      token: "",
    },
    ///将state中的数据进行加工
    getters: {
      bigSum(state) {
        return state.data * 10;
      },
    },
  };
  